package com.li.service;

import com.li.dao.ProjectReportMapper;
import com.li.model.ProjectReport;
import com.li.model.UserProject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Optional;

@Service
public class ProjectReportServiceImpl implements ProjectReportService{
    @Autowired
    private ProjectReportMapper reportMapper;

    @Override
    public Optional<ProjectReport> queryReportById(long id) {
        ProjectReport report = reportMapper.queryReportById(id);
        if (report == null){
            return Optional.empty();
        }
        return Optional.of(report);
    }

    @Override
    public List<ProjectReport> queryAllReportByPid(long pid) {
        return reportMapper.queryAllReportByPid(pid);
    }

    @Override
    public void addReport(ProjectReport projectReport) {
        projectReport.setCreateTime(new Date());
        reportMapper.addReport(projectReport);
    }

    @Override
    public void updateReport(ProjectReport projectReport) {
        reportMapper.updateReport(projectReport);
    }

    @Override
    public void deleteReport(long id) {
        reportMapper.deleteReport(id);
    }

}
